﻿/*****************************************************************//**
 * @file    GraphMarkProvider.h
 * @brief   三维符号可视化数据管理。
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-11-13
 *********************************************************************/

#ifndef __GraphMarkProvider_H__
#define __GraphMarkProvider_H__

#include "GraphProviderBase.h"

#include "GraphDataProviderAPI.h"

#include <QHash>

// 前置声明
namespace Exchange
{
    class FITKAcousticsVTKGraphObjectScalarBars;
}

namespace GraphData
{
    /**
     * @brief   三维符号可视化数据分类管理类。
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-11-13
     */
    class GRAPHDATAPROVIDERAPI GraphMarkProvider : public GraphProviderBase
    {
        Q_OBJECT

        // 友元，防止外部手动创建或析构。
        friend class GraphProviderManager;

    public:
        /**
         * @brief   获取当前算例已实例化的可视化对象。[重写]
         * @return  可视化对象列表。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        QList<Exchange::FITKAcousticsVTKGraphObject3D*> getCurrentGraphObjs() override;

        /**
         * @brief   获取当前算例已实例化的相机敏感可视化对象。（外部进行局部刷新）[重写]
         * @return  可视化对象列表。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        QList<Exchange::FITKAcousticsVTKGraphObject3D*> getCurrentCameraSenGraphObjs() override;

        /**
         * @brief   获取类名。[重写]
         * @return  类名
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        QString getClassName() override;

        /**
         * @brief   根据数据ID更新可视化对象，没有则跳出。[虚函数]
         * @param   dataId：数据ID
         * @param   forceUpdate：强制刷新[缺省]
         * @return  是否存在该数据ID所对应可视化对象。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        bool updateObjById(int dataId, bool forceUpdate = false) override;
        /**
         * @brief    更具数据ID获取SEA连接可视化对象。（没有则创建）
         * @param[i] dataObjId                                       数据id
         * @param[i] forceUpdate                                     是否强制刷新
         * @return   Exchange::FITKAcousticsVTKGraphObject3D*        可视化对象
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-01-16
         */
        Exchange::FITKAcousticsVTKGraphObject3D* getJunctionGraphObject(int dataObjId, bool forceUpdate = false);

        /**
         * @brief   获取全部连接关系可视化对象。（没有则创建）
         * @param   autoCreate：自动创建不存在的可视化对象[缺省]
         * @return  可视化对象列表
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        QList<Exchange::FITKAcousticsVTKGraphObject3D*> getAllJunctionGraphObjects(bool autoCreate = true);

        /**
         * @brief   获取全部连接关系可视化对象。（没有则创建）
         * @param   junctionTypeEnum：连接关系类型枚举值
         * @param   update：刷新可视化对象[缺省]
         * @return  可视化对象列表
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        QList<Exchange::FITKAcousticsVTKGraphObject3D*> getJunctionGraphObjectsByType(int junctionTypeEnum, bool update = true);

        /**
         * @brief   获取模型内自由边可视化对象。
         * @param   autoCreate：自动创建不存在的可视化对象[缺省]
         * @return  可视化对象
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-14
         */
        Exchange::FITKAcousticsVTKGraphObject3D* getSEAFreeEdgesGraphObject(bool autoCreate = false);

        /**
         * @brief   根据数据ID获取载荷可视化对象。（没有则创建）
         * @param   dataObjId：数据ID
         * @return  可视化对象
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-26
         */
        Exchange::FITKAcousticsVTKGraphObject3D* getLoadGraphObject(int dataObjId);

        /**
         * @brief   获取全部载荷可视化对象。（没有则创建）
         * @param   autoCreate：自动创建不存在的可视化对象[缺省]
         * @return  可视化对象列表
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-26
         */
        QList<Exchange::FITKAcousticsVTKGraphObject3D*> getAllLoadGraphObjects(bool autoCreate = true);
        /**
         * @brief   根据数据ID获取对应可视化对象。（没有则不创建）
         * @param   dataObjId：数据ID
         * @return  可视化对象
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        Exchange::FITKAcousticsVTKGraphObject3D* getCurrentGraphObjByDataId(int dataObjId);
        /**
         * @brief    获取方向可视化对象
         * @param    dataObjId                                                   数据ID
         * @return   Exchange::FITKAcousticsVTKGraphObject3D*                    可视化对象
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-20
         */
        Exchange::FITKAcousticsVTKGraphObject3D* getDirectionGraphObj(int& dataObjID);
        /**
         * @brief    释放工具渲染对象
         * @param[i] dataObjID                 对象id
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-21
         */
        void deleteToolGraphObj(int dataObjID);

        /**
         * @brief   设置是否激活双击可拾取对象的拾取状态。[重写]
         * @param   pickable：是否可拾取
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void setDoubleClickPickable(bool pickable) override;

        /**
         * @brief   设置全部类型SEA连接关系是否可拾取。
         * @param   pickable：是否可拾取
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void setSEAJunctionsPickable(bool pickable);
        /**
         * @brief    设置FE所有连接是否可拾取
         * @param[i] pickable                        是否可拾取
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-10
         */
        void setFEJunctionsPickable(bool pickable);
        /**
         * @brief    设置混合所有连接是否可拾取
         * @param[i] pickable                        是否可拾取
         * @author   BaGuijun (baguijun@163.com)
         * @date     2025-02-10
         */
        void setHybridJunctionsPickable(bool pickable);
        /**
         * @brief   设置SEA连接点是否可拾取。
         * @param   pickable：是否可拾取
         * @param   dataObjId：生效数据ID（-1则对所有数据生效）[缺省]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void setSEAJunctionPointPickable(bool pickable, int dataObjId = -1);

        /**
         * @brief   设置SEA连接线是否可拾取。
         * @param   pickable：是否可拾取
         * @param   dataObjId：生效数据ID（-1则对所有数据生效）[缺省]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void setSEAJunctionLinePickable(bool pickable, int dataObjId = -1);

        /**
         * @brief   设置SEA连接面是否可拾取。
         * @param   pickable：是否可拾取
         * @param   dataObjId：生效数据ID（-1则对所有数据生效）[缺省]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        void setSEAJunctionAreaPickable(bool pickable, int dataObjId = -1);

        /**
         * @brief   设置全部载荷是否可拾取。
         * @param   pickable：是否可拾取
         * @param   dataObjId：生效数据ID（-1则对所有数据生效）[缺省]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-26
         */
        void setLoadsPickable(bool pickable, int dataObjId = -1);

        /**
         * @brief   获取后处理色棒组可视化对象。
         * @return  可视化对象
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        Exchange::FITKAcousticsVTKGraphObjectScalarBars* getScalarBarsGraphObject();

    private:
        /**
         * @brief   构造函数。
         * @param   graphWidget：可视化窗口
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        GraphMarkProvider(Comp::FITKGraph3DWindowVTK* graphWidget);

        /**
         * @brief   析构函数。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        ~GraphMarkProvider();

    private:      
        /**
         * @brief   SEA自由边可视化对象字典。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-14
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_SEAFreeEdgesObjHash;

        /**
         * @brief   SEA连接点可视化对象字典。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-13
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_SEAJuncPointObjHash;
        /**
         * @brief   合并SEA连接线可视化对象字典。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-20
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_SEAJuncLinesObjHash;

        /**
         * @brief   合并SEA连接区域可视化对象字典。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-20
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_SEAJuncAreasObjHash;
        /**
         * @brief  混合点连接可视化对象字典
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-08
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_HybridJuncPointObjHash;
        /**
         * @brief  混合点连接可视化对象字典
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-08
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_HybridJuncLinesObjHash;
        /**
         * @brief  混合点连接可视化对象字典
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-08
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_HybridJuncAreasObjHash;
        /**
         * @brief  FE点连接可视化对象字典
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-08
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_FEJuncPointObjHash;
        /**
         * @brief  FE点连接可视化对象字典
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-08
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_FEJuncLinesObjHash;
        /**
         * @brief  FE点连接可视化对象字典
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-08
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_FEJuncAreasObjHash;

        /**
         * @brief   力矩可视化对象字典。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-26
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_loadPointForceObjHash;

        /**
         * @brief   功率可视化对象字典。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-26
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_loadPowerObjHash;

        /**
         * @brief   约束可视化对象字典。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-26
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_loadConstraintObjHash;
        /**
         * @brief  噪声载荷可视化对象字典
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-01-18
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_importNoiseHVACHash;
        /**
         * @brief  单极子载荷可视化对象字典
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-01-18
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_loadMonopoleObjHash;
        /**
         * @brief   后处理色棒组可视化对象。
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        Exchange::FITKAcousticsVTKGraphObjectScalarBars* m_scalarBarObj{ nullptr };
        /**
         * @brief  渲染工具可视化对象id
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-21
         */
        static int m_graphToolId;
        /**
         * @brief  工具可视化对象字典
         * @author BaGuijun (baguijun@163.com)
         * @date   2025-02-20
         */
        QHash<int, Exchange::FITKAcousticsVTKGraphObject3D*> m_graphToolObjHash = {};

    };
}   // namespace GraphData

#endif // __GraphMarkProvider_H__
